<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('币种列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="notice-form">
                <div class="select-list">
                    <ul>
                        <li>
                            币种名称：<input type="text" name="symbol" />
                        </li>
                        <li>
                            持币人数> <input type="number" name="holders" />
                        </li>
                        <li>
                            危险系数《 <input type="number" name="risk_score" />
                        </li>
                        <li>
                            买入状态：<select name="is_buy">
                                <option value="">所有</option>
                                <option value="Y">已买入</option>
                            </select>
                        </li>
                        <li>
                            卖出状态：<select name="is_sell">
                                <option value="">所有</option>
                                <option value="Y">已卖出</option>
                            </select>
                        </li>
                        <li>
                            卖出状态：<select name="is_sell">
                            <option value="">所有</option>
                            <option value="Y">已卖出</option>
                        </select>
                        </li>


                        <li class="select-time">
                            <label>创建时间> </label>
                            <input type="text" class="time-input"  placeholder="开始时间"
                                   name="beginTime"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var prefix = ctx + "coin/token";

        $(function () {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                zfUrl: prefix + "/zf",
                modalName: "币种列表",
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: 'ID',
                    },
                    {
                        field: 'chain_type',
                        title: '链路类型'
                    },
                    {
                        title: '币种信息',
                        formatter: function (value, row, index) {
                            var div = $.table.isnull("币种名称：", row.symbol, "</br>");
                            div += $.table.isnull("合约地址：","<a target='_blank' href='https://ave.ai/token/"+row.token_address+"-"+row.chain_type+"'>"+ row.token_address+"</a>", "</br>");
                            div += $.table.isnull("市　　值：", row.market_cap, "U</br>");
                            div += $.table.isnull("持币人数：", row.holders, "</br>");
                            return div;
                        }
                    },
                    {
                        title: '买/卖状态',
                        formatter: function (value, row, index) {
                            var div = "";
                            if(row.is_buy !=null && row.is_buy=='Y'){
                                div += $.table.isnull("", "<span class='badge badge-primary'>已买入</span>", "</br>");
                            }
                            if(row.is_sell !=null && row.is_sell=='Y'){
                                div +=  $.table.isnull("", "<span class='badge badge-warning mt5'>已卖出</span>", "</br>");
                            }
                            return div;
                        }
                    },
                    {
                        field: 'create_time_str',
                        title: '创建时间',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var div = $.table.isnull("", row.create_time_str, "</br>");
                            return div;
                        }
                    }
                ]
            };
            $.table.init(options);
        });
        /*字典列表-详细*/
        function detail(id) {
            var url = prefix + '/address/index/' + id;
            $.modal.openTab("持币统计", url);
        }
    </script>
</body>

</html>